import tkinter as tk
import tkinter.ttk as ttk
from modData import modData
from tkinter import messagebox,StringVar
from viewRender import viewRender as vr
import json
import shelve
import string


#这个版本的mod不能和配置json里面的id重复，否则无法加载，会直接报错
jsonpath=r'C:\Program Files (x86)\Steam\steamapps\common\鬼谷八荒\Mod\modFQA\配置修改教程\配置（只读）Json格式'
modpath=r"C:\data\mod_0509\ModProject_ufBJlO"
md=modData()
data =md.modRead(modpath)
db=shelve.open('my_db')

md.read_dramaDialogue()

# drama=md.dialogueMake()

def getallchild(self,data):
    if type(data)==dict:
        for i in data:
            if i =='condition'and data[i]!={'groupName': [], 'items': []}:
                res=data[i]['items']
                self.conditions.extend(res)
            if i =='function' and data[i]!={'groupName': [], 'items': []}:
                self.functions.extend(data[i]['items'])
            child = data[i]
            if type(child)==dict:
                getallchild(self,child)
            else:
                if child in ["",[],{}]:
                    continue  
                if type(child)==int:
                    continue  
                if type(child)==string:
                    strs.append(child)
                    continue   
                if type(child)==list:
                    for t in child:
                        if type(t)==dict:
                            getallchild(self,t)
    if type(data) == list:
        for i in data:
            getallchild(self,i)


# getallchild(md,data)

# rewardCount = list(filter(lambda x:x['key']=={'value': 'rewardCount'},md.functions))
# rewards=[]
# for i in rewardCount:
#     if i['values'][0]['value']!="":
#         res = json.loads(i['values'][0]['value'])
#     getallchild(md,res)
#     ss=0
# ss=0
db.close()

ss=0


